package com.example.es;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

/**
 * @Author：wlz
 * @Package：com.example.es
 * @Project：redis
 * @name：ESTest_Index_Create
 * @Date：2023/4/15 22:18
 * @Filename：ESTest_Index_Create
 */
public class ESTest_Index_Delete {
    public static void main(String[] args) throws IOException {
        //创建
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost",9200)));
        //查询索引
        DeleteIndexRequest request = new DeleteIndexRequest("user1");
        AcknowledgedResponse response = restHighLevelClient.indices().delete(request, RequestOptions.DEFAULT);

        //响应状态
        System.out.println(response.isAcknowledged());

        //关闭
        restHighLevelClient.close();
    }
}
